package com.gph.saviorframework.echarts.test.bar;

import com.gph.saviorframework.echarts.axis.CategoryAxis;
import com.gph.saviorframework.echarts.axis.ValueAxis;
import com.gph.saviorframework.echarts.code.*;
import com.gph.saviorframework.echarts.data.PointData;
import com.gph.saviorframework.echarts.feature.MagicType;
import com.gph.saviorframework.echarts.series.Bar;
import com.gph.saviorframework.echarts.test.util.EnhancedOption;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class BarTest2 {

    @Test
    public void test() {
        //地址：http://echarts.baidu.com/doc/example/bar1.html
        EnhancedOption option = new EnhancedOption();
        option.title().text("堆积柱状图例子");
        option.tooltip().trigger(Trigger.axis);
        option.legend("直接访问","邮件营销","联盟广告","视频广告","搜索引擎","百度","谷歌","必应","其他");
        option.toolbox().show(true).feature(Tool.mark, Tool.dataView,
                new MagicType(Magic.line, Magic.bar,Magic.stack,Magic.tiled).show(true),
                Tool.restore,
                Tool.saveAsImage).orient(Orient.vertical).x(X.right).y(Y.center);

        option.calculable(true);

        option.xAxis(new CategoryAxis().data("周一","周二","周三","周四","周五","周六","周日"));
        option.yAxis(new ValueAxis().type(AxisType.value));

        Bar bar = new Bar("直接访问");
        bar.data(320, 332, 301, 334, 390, 330, 320);

        Bar bar2 = new Bar("邮件营销");
        bar2.data(120, 132, 101, 134, 90, 230, 210);

        Bar bar3 = new Bar("联盟广告");
        bar3.data(220, 182, 191, 234, 290, 330, 310);

        Bar bar4 = new Bar("视频广告");
        bar4.data(150, 232, 201, 154, 190, 330, 410);

        Bar bar5 = new Bar("搜索引擎");
        bar5.data(862, 1018, 964, 1026, 1679, 1600, 1570);
        bar5.markLine().itemStyle().normal().lineStyle().type(LineType.dashed);
        List<PointData> pointDatas = new ArrayList<PointData>();
        pointDatas.add(new PointData().type(MarkType.min).name("最小值"));
        pointDatas.add(new PointData().type(MarkType.max).name("最大值"));
        bar5.markLine().data(pointDatas);

        Bar bar6 = new Bar("百度");
        bar6.setBarWidth(5);
        bar6.data(620, 732, 701, 734, 1090, 1130, 1120);

        Bar bar7 = new Bar("谷歌");
        bar7.data(120, 132, 101, 134, 290, 230, 220);

        Bar bar8 = new Bar("必应");
        bar8.data(60, 72, 71, 74, 190, 130, 110);

        Bar bar9 = new Bar("必应");
        bar9.data(62, 82, 91, 84, 109, 110, 120);

        option.series(bar, bar2, bar3, bar4, bar5,bar6,bar7,bar8,bar9);
        option.exportToHtml("bar2.html");
        option.view();
    }
}
